<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        /*猜数字游戏
        function getRandom(m, n){
            return parseInt(Math.random() * (n - m) + m)
        }
        function game(){
            var n = getRandom(1, 10)
            while(true){
                var a = prompt("请输入数字")
                a = parseInt(a)
                if(a == n){
                    alert("猜对了")
                    break
                }else if(a < n){
                    alert("猜小了")
                }else if(a > n){
                    alert("猜大了")
                }
            }
        }
        game()*/




        /*倒计时
        function countDown(){
            var nowDate = new Date()
            var jiaDate = new Date("2025-10-1 00:00:00")
            var time = jiaDate - nowDate
            time = time / 1000
            var d = parseInt(time / 60 /60 / 24)
            d = d < 10 ? "0" + d : d
            var h = parseInt(time / 60 /60 % 24)
            h = h < 10 ? "0" + h : h
            var m = parseInt(time / 60 % 60)
            m = m < 10 ? "0" + m : m
            document.write("<b>距离国庆：</b>" + d +"天" + h +"小时"+m+"分钟")
        }
        countDown()*/



        /*字符串*/
        function checkName(){
            var userName = prompt("用户名")
            if(userName.length < 3 || userName.length > 10){
                return false
            }
            var userName1 = userName.toLocaleUpperCase()
            var userName2 = userName.toLowerCase()
            if (userName1.indexOf("ADMIN") >=0 ||
                userName2.indexOf("admin") >= 0){
                    alert("不能包含admin关键词")
                    return false
                }
                return true
        }
        checkName()



    </script>
</body>
</html>